package com.health.controller.manage;


import com.health.common.R;
import com.health.pojo.OrderSet;
import com.health.service.OrderSetService;
import com.health.vo.OrderSetVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/api/manage/orderSet")
@RequiredArgsConstructor
@Slf4j
@Api(tags = "预约设置管理")
public class OrderSetController {

    private final OrderSetService orderSetService;

    @ApiOperation(value = "获取预约设置数据")
    @GetMapping("/getCalendarData")
    public R getCalendarDataByMonth(Integer currentYear, Integer currentMonth) {
        log.info("获取预约设置数据 {} {}", currentYear, currentMonth);
        List<OrderSetVO> list = orderSetService.getCalendarDataByMonth(currentYear, currentMonth);
        return R.success(list);
    }

    @PutMapping
    @ApiOperation(value = "更新预约设置数据")
    public R updateOrderSet(@RequestBody OrderSet orderSet) {
        log.info("更新预约设置数据 {}", orderSet);
        orderSetService.updateOrderSet(orderSet);
        return R.success();
    }


    @ApiOperation(value = "上传预约设置数据")
    @PostMapping("/upload")
    public R uploadExel(MultipartFile excelFile) {
        log.info("上传预约设置数据 {}", excelFile);
        orderSetService.parseExcel(excelFile);
        return R.success();
    }
}
